package com.tdcode.ch1;

/**
 * @className: Movie
 * @description: 影片
 * @author: cyd
 * @date: 2021/11/29 下午5:49
 **/

public class Movie {

    /** 普通片 */
    public static final int REGULAR = 0;
    /** 新片 */
    public static final int NEW_RELEASE = 1;
    /** 儿童片 */
    public static final int CHILDRENS = 2;

    /** 影片名称*/
    private String title;
    /**类型*/
    private Price _price;

    public Movie(String title, Integer priceCode) {
        this.title = title;
        setPriceCode(priceCode);
    }

    int getFrequentRenterPoints(int daysRented) {
        return _price.getFrequentRenterPoints(daysRented);
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Integer getPriceCode() {
        return _price.getPriceCode();
    }

    public void setPriceCode(Integer arg) {
        switch (arg) {
            case REGULAR:
                _price = new RegularPrice();
                break;
            case NEW_RELEASE:
                _price = new NewReleasePrice();
                break;
            case CHILDRENS:
                _price = new ChildrensPrice();
                break;
            default:
                throw new IllegalArgumentException("Incorrect Price Code");
        }
    }

    double getCharge(int daysRented){
        return _price.getCharge(daysRented);
    }
}
